home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
5
/
CHASSIS_
/
FILEOPEN.C
< prev
next >
Wrap
Text File
|
1992-05-14
|
3KB
|
69 lines
/****************************************************************************************/
/* FileOpenProc */
/****************************************************************************************/
#include "MyHeaders.h"
int FileOpenProc ()
{
int FORetCode = 0;
SFTypeList workTypeList;
Rect dlogRect;
int rectHeight, rectWidth;
int newH, newV;
int itemHit; /* return from modal dialog */
myDlogPtr = GetNewDialog (getDlgID, NIL, (WindowPtr) -1); /* get the dialog */
dlogRect = (*myDlogPtr).portRect; /* position dlog on desktop */
rectHeight = dlogRect.bottom - dlogRect.top;
rectWidth = dlogRect.right - dlogRect.left;
newH = (screenBits.bounds.right - rectWidth) * .50; /* centered horizonally */
newH += 2; /* jive it in */
if (newH < 10) /* (not less than 10) */
newH = 10;
newV = ((screenBits.bounds.bottom - 30 /* vertical position */
- rectHeight)* (.33)) + 30; /* one-third down */
if (newV < 30) /* (not less than 30) */
newV = 30;
if (appIndex <= appCount) /* if Finder has selection */
{
GetAppFiles (appIndex, &appTheFile); /* get the info from Finder */
workReply.good = TRUE; /* transfer to work area */
workReply.vRefNum = appTheFile.vRefNum; /* ditto */
workReply.fType = appTheFile.fType; /* ditto */
workReply.version = appTheFile.versNum; /* ditto */
workReply.fName[0] = appTheFile.fName[0]; /* ditto */
strncpy ((char *) &workReply.fName[1], /* ditto */
(char *) &appTheFile.fName[1],
appTheFile.fName[0]);
}
else /* otherwise */
/* get info from SF dialog */
{
workTypeList[0] = (long) 'TEXT'; /* set up to four types */
workTypeList[1] = (long) 'ttro'; /* set up to four types */
SetPt (&workPoint, newH,newV); /* upper left corner */
SFGetFile (workPoint, NIL, NIL, 2, workTypeList, NIL, &workReply);
if (workReply.good == FALSE) /* if cancel */
{
FORetCode = 1; /* set bad ret code */
goto ENDING; /* get out */
}
}
workRC = FSOpen (&workReply.fName, /* open the file */
workReply.vRefNum, &workPathRefNum);
if (workRC != noErr)
{
ParamText (&workReply.fName,"","",""); /* set text as file name */
PlaceAlert (134); /* position the alert */
StopAlert (134, NIL); /* show the alert */
FORetCode = 1; /* set bad ret code */
}
ENDING:
return FORetCode;
}